<?php if (!$this->Auth->is_logged()): ?>
	<h1>Erro</h1>
	<div class="info"><div class="message">Voc&ecirc; precisa estar logado para poder acessar esta p&aacute;gina.</div></div>
<?php else: ?>
	<h1>Meus Personagens</h1>
	<?php $characters = $this->Account->get_characters($this->Auth->logged()) ?>
	<?php if (empty($characters)): ?>
		<div class="info"><div class="message">Voc&ecirc; n&atilde;o possui nenhum personagens no momento.</div></div>
	<?php else: ?>
		<div id="characters">
			<?php foreach ($characters as $character): ?>
				<div class="character">
					<?php $class = isset($_GET['name']) && base64_decode($_GET['name']) == $character['name'] ? array('class' => 'active') : array() ?>
					<?php echo $this->link($this->image($character['avatar_path'], array('width' => 90, 'height' => 105)) . '<br />' . $character['name'], '/character/' . base64_encode($character['name']), $class) ?>
				</div>
			<?php endforeach ?>
		</div>
		<div class="clear"></div>
		<?php if (isset($_GET['name'])): ?>
			<?php $name = base64_decode($_GET['name']) ?>
			<?php if (!$this->Character->in_account($name, $this->Auth->logged())): ?>
				<h1>Erro</h1>
				<div class="info"><div class="message">Este personagem n&atilde;o existe ou n&atilde;o pertence a sua conta.</div></div>
			<?php else: ?>
				<h1>Personagem <?php echo $name ?></h1>
			<?php endif ?>
		<?php endif ?>
	<?php endif ?>
<?php endif ?>